/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Bussiness;

import DAO.AccessDatabase;
import DAO.Customer;

/**
 *
 * @author User
 */
public class CustomManage {
    private AccessDatabase astd = new AccessDatabase();
    private CustomeTable model;
    //dung singleton
    private static CustomManage _manager;

    public static CustomManage getManager(){
        if(_manager == null){
            _manager = new CustomManage();
        }
        return _manager;
    }
    //get Customer to table

    public CustomeTable getCustomer() throws Exception {

        model = new CustomeTable(astd.getCustomer());
        return model;
    }
    //add customer
    public void addCustomer(Customer c) throws Exception {
        astd.AddCustomer(c);
        model.AddCustomer(c);
    }
    //update customer
     public void updateCustomer(Customer c) throws Exception {
        astd.UpdateCustomer(c);
        model.UpdateCustomer(c);
    }
     //delete customer
      public void deleteCustomer(Customer c) throws Exception {
        astd.DeleteCustomer(c);
        model.DeleteCustomer(c);
    }
     public CustomeTable SearchCustomer(String name) throws Exception {
        model = new CustomeTable(astd.SearchCustomer(name));
        return model;
     }
}
